﻿using System;
using System.Data;
namespace Dapper {
    /// <summary>
    /// This class represents a SQL string, it can be used if you need to denote your parameter is a Char vs VarChar vs nVarChar vs nChar
    /// <summary>
    /// Handles variances in features per DBMS
    /// </summary>
    partial class FeatureSupport {
        private static readonly FeatureSupport
            @default = new FeatureSupport(false),
            postgres = new FeatureSupport(true);
        /// <summary>
        /// Gets the feature set based on the passed connection
        /// </summary>
        public static FeatureSupport Get(IDbConnection connection) {
            string name = connection == null ? null : connection.GetType().Name;
            if( string.Equals(name ,"npgsqlconnection" ,StringComparison.OrdinalIgnoreCase) )
                return postgres;
            return @default;
        }
        private FeatureSupport(bool arrays) {
            Arrays = arrays;
        }
        /// <summary>
        /// True if the db supports array columns e.g. Postgresql
        /// </summary>
        public bool Arrays { get; private set; }
    }
}
